package xtable;

// typed table access point
public class Roles {
	Roles() {
	}

	public static xdb.util.AutoKey<Long> getAutoKey() {
		return _Tables_.getInstance().roles.getAutoKey();
	}

	public static Long nextKey() {
		return getAutoKey().next();
	}

	public static Long insert(xbean.Role value) throws Exception {
		Long next = nextKey();
		insert(next, value);
		return next;
	}

	public static void firstInsert(Long key, xbean.Role value) throws Exception {
		if (!xdb.Xdb.getInstance().validateInsertRoleRecord(key)) {
			throw new RuntimeException("can not insert rolelock refrence record while roleid is invalidate! k=" + key);
		}
		_Tables_.getInstance().roles.firstInsert(key, value);
	}

	public static xbean.Role get(Long key) throws Exception {
		return _Tables_.getInstance().roles.get(key);
	}

	public static xbean.Role get(Long key, xbean.Role value) throws Exception {
		return _Tables_.getInstance().roles.get(key, value);
	}

	public static void insert(Long key, xbean.Role value) throws Exception {
		if (!xdb.Xdb.getInstance().validateInsertRoleRecord(key)) {
			throw new RuntimeException("can not insert rolelock refrence record while roleid is invalidate! k=" + key);
		}
		_Tables_.getInstance().roles.insert(key, value);
	}

	public static void delete(Long key) throws Exception {
		_Tables_.getInstance().roles.delete(key);
	}

	public static boolean add(Long key, xbean.Role value) throws Exception {
		if (!xdb.Xdb.getInstance().validateInsertRoleRecord(key)) {
			throw new RuntimeException("can not add rolelock refrence record while roleid is invalidate! k=" + key);
		}
		return _Tables_.getInstance().roles.add(key, value);
	}

	public static boolean remove(Long key) throws Exception {
		return _Tables_.getInstance().roles.remove(key);
	}

	public static xdb.TTableCache<Long, xbean.Role> getCache() {
		return _Tables_.getInstance().roles.getCache();
	}

	public static xdb.TTable<Long, xbean.Role> getTable() {
		return _Tables_.getInstance().roles;
	}

	public static xbean.Role select(Long key) throws Exception {
		return getTable().select(key, new xdb.TField<xbean.Role, xbean.Role>() {
			public xbean.Role get(xbean.Role v) {
				return v.toData();
			}
		});
	}

	public static xbean.Role selectWithoutCache(Long key) throws Exception {
		return getTable().selectWithoutCache(key, new xdb.TField<xbean.Role, xbean.Role>() {
			public xbean.Role get(xbean.Role v) {
				return v.toData();
			}
		});
	}

	public static xbean.Role selectWithoutCache4Rollback(Long key) throws Exception {
		return getTable().selectWithoutCache4Rollback(key, new xdb.TField<xbean.Role, xbean.Role>() {
			public xbean.Role get(xbean.Role v) {
				return v.toData();
			}
		});
	}

	public static String selectRolename(Long key) throws Exception {
		return getTable().select(key, new xdb.TField<xbean.Role, String>() {
				public String get(xbean.Role v) {
					return v.getRolename();
				}
			});
	}

	public static Long selectUserid(Long key) throws Exception {
		return getTable().select(key, new xdb.TField<xbean.Role, Long>() {
				public Long get(xbean.Role v) {
					return v.getUserid();
				}
			});
	}

	public static Long selectLastlogintime(Long key) throws Exception {
		return getTable().select(key, new xdb.TField<xbean.Role, Long>() {
				public Long get(xbean.Role v) {
					return v.getLastlogintime();
				}
			});
	}

}
